<?php
class abuso
{
    public function curPageURL() 
    {
        $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].
        $_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].
        $_SERVER['REQUEST_URI'];
        return $url;
    }
    public function reportarAbuso()
    {		        
        
        if (!isset($_SESSION))
            session_start();
        include_once($_SESSION['dir'].'/basedatos.php');
        $mensaje = $_POST['message'];
        $tipo = $_POST['tipo'];        
        $database = new BaseDatos();
        $pagina = $_POST['url'];
        $idD = $_SESSION['k_username'];
        $name[] = "usrname";
        $persona[] = $_SESSION["k_username"];
        $user = $database->select2("perfil",$persona,$name);
        $nombreC =$user[6] . " " . $user[7];
        $arr2 = array("",$nombreC, $idD, NULL ,$mensaje,$tipo, $pagina, "No leido");
        $database->insertarAbuso($arr2);
         echo "El abuso ha sido reportado. Gracias";
    }
    
    function conseguirAbusos()
        {
            include_once($_SESSION['dir'].'/basedatos.php');
            $data = new BaseDatos();
            $arr = $data->mostrarAbusos();
            return $arr;
        }
    function mostrarAbuso()
        {
            include_once($_SESSION['dir'].'/basedatos.php');
            if(isset($_GET['id'])) 
		{
			$id = $_GET['id'];
			$database = new BaseDatos();
			$arr= $database->mostrarAbuso($id);						
			return $arr;
		}
		else
                {
                    echo "error";
                    return null;
                }
        }
        
        function solucionarAbuso()
        {
            
            include_once($_SESSION['dir'].'/basedatos.php');
            if(isset($_POST['solucionar'])) 
		{
			$id = $_POST['solucionar'];
			$database = new BaseDatos();
			$arr = $database->solucionarAbuso($id);
                        header( 'Location: /rspinf-usb/administrador/verAbusos.php' );
			return;
		}
		else
                {
                    echo "error";
                    return null;
                }
        }
}
?>